package cn.fxl.hystrix;

import cn.fxl.ajax.AjaxResult;
import cn.fxl.domain.MoveUser;
import cn.fxl.domain.Movie;
import cn.fxl.feign.MovieFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class MovieHystrix implements FallbackFactory<MovieFeign> {
    @Override
    public MovieFeign create(Throwable throwable) {
        return new MovieFeign() {
            @Override
            public List<Movie> movieGetAll() {
                Movie movie = new Movie();
                movie.setId(-1L);
                movie.setName("熔断");
                ArrayList<Movie> movies = new ArrayList<>();
                movies.add(movie);
                return movies;
            }

            @Override
            public Movie getOne(Long id) {
                Movie movie = new Movie();
                movie.setId(-1L);
                movie.setName("熔断");
                return movie;
            }

            @Override
            public AjaxResult moveGetOne(Long id) {
                return new AjaxResult(false,"熔断");
            }

            @Override
            public AjaxResult update(MoveUser moveUser) {
                return new AjaxResult(false,"熔断");
            }

            @Override
            public AjaxResult saveAdd(MoveUser moveUser) {
                return new AjaxResult(false,"熔断");
            }

            @Override
            public AjaxResult UpdateByMovie(Movie movie) {
                return new AjaxResult(false,"熔断");
            }
        };
    }
}
